package com.jingtai.shop.webfacade.bo.shopcar;

import cn.hutool.core.util.ObjectUtil;
import com.jingtai.common.webfacade.BaseBO;
import com.jingtai.common.webfacade.error.CommonException;
import com.jingtai.common.webfacade.error.ErrorEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

/**
 * 购物车添加商品
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class ShopCarAddBO extends BaseBO {

    /**
     * 商品的id
     */
    private Long goodsId;

    /**
     * sku 编码
     */
    private String skuCode;

    /**
     * 商品数量
     */
    private Long quantity;

    @Override
    public void validate() {
        super.validate();

        if (ObjectUtil.isEmpty(goodsId)
                || StringUtils.isBlank(skuCode)
                || ObjectUtil.isEmpty(quantity)) {
            throw new CommonException(ErrorEnum.REQUIRED_PARAM_EMPTY);
        }
    }
}
